/**
 * 
 */
package co.fitstart.payment.service.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericJdbcSupport;

import co.fitstart.payment.entity.channel.Channel;
import co.fitstart.payment.service.ChannelService;

/**
 * @author lute
 *
 */
@Service("channelService")
public class ChannelServiceImpl implements ChannelService {

    @Autowired
    private GenericJdbcSupport genericJdbcSupport;
    
    /* (non-Javadoc)
     * @see cn.xcm.payment.service.ChannelService#load(java.lang.Long)
     */
    public Channel load(Long id) {
        String sentence = "SELECT id AS id, name AS name, platform AS platform_as_int, once_upper_limit AS once_upper_limit, day_upper_limit AS day_upper_limit, is_disabled AS disabled FROM channel WHERE id = :id";
        List<Channel> result = genericJdbcSupport.queryForList(sentence, "id", id, Channel.class);
        return CollectionUtils.isNotEmpty(result) ? result.get(0) : null;
    }

}
